<template>
  <div>
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="抢单成功的用户" name="first" @click="empoloyer">
        抢单成功的用户
        <el-table :data="elist" border style="width: 100%">
          <el-table-column fixed prop="code" label="订单编号" width="150">
          </el-table-column>
          <el-table-column fixed="right" label="操作" width="100">
            <template slot-scope="scope">
              <el-button
                @click="upempoloyer(scope.row.code)"
                type="text"
                size="small"
                >同意</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="雇主同意的订单" name="second" @click="aggreempoloyer">
        雇主同意的订单
        <el-table :data="alist" border style="width: 100%">
          <el-table-column fixed prop="code" label="订单编号" width="150">
          </el-table-column>
          <el-table-column fixed="right" label="操作" width="100">
            <template slot-scope="scope">
              <el-button
                @click="accempoloyer(scope.row.code)"
                type="text"
                size="small"
                >提交</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="展示完成的订单" name="third" @click="projectempoloyer">
        展示完成的订单
        <el-table :data="plist" border style="width: 100%">
          <el-table-column fixed prop="code" label="订单编号" width="150">
          </el-table-column>
          <el-table-column fixed="right" label="操作" width="100">
            <template slot-scope="scope">
              <el-button
                @click="remit(scope.row.code)"
                type="text"
                size="small"
                >打款</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
export default {
  data() {
    return {
      activeName: "second",
      elist: [], //抢单成功的用户，
      alist: [], //雇主同意的订单
      plist: [], //展示完成的订单
      userid:localStorage.getItem('userid')
    };
  },
  methods: {
    // handleClick(row) {
    //     console.log(row);
    //   },
    // 雇主确认
    upempoloyer(code) {
      this.axios.get("upempoloyer?code=" + code).then((res) => {
        alert(res.data.msg);
      });
    },
    //   展示抢单成功的用户
    empoloyer() {
      this.axios.get("empoloyer?userid="+this.userid).then((res) => {
        this.elist = res.data.data;
      });
    },
    // 展示雇主同意的订单
    aggreempoloyer() {
      this.axios.get("aggreempoloyer?userid="+this.userid).then((res) => {
        this.alist = res.data.data;
      });
    },
    // 项目完成确认
    accempoloyer(code) {
      this.axios.get("accempoloyer?code=" + code).then((res) => {
        alert(res.data.msg);
      });
    },
    //项目完成的订单
    projectempoloyer() {
      this.axios.get("projectempoloyer?userid="+this.userid).then((res) => {
        this.plist = res.data.data;
      });
    },
    //打款
    remit(code) {
      this.axios.get("remit?code=" + code).then((res) => {
        alert(res.data.msg);
      });
    },
  },
  mounted(){
    this.empoloyer()
    this.aggreempoloyer()
    this.projectempoloyer()
  }
};
</script>

<style>
</style>